There have been proposed various storage devices for terminal devices. Among such storage devices is, for example, a flash memory. In recent years, a type of flash memory called NAND flash memory has been increasingly used.
The NAND flash memory is a nonvolatile semiconductor memory that needs to be erased before new data is written. The life depends on the number of times of erasure and erasure time intervals. It is preferable to equally use the blocks to prolong the life of the NAND flash memory.
In view of this, wear leveling techniques have recently been proposed. In the wear leveling techniques, erasure time and the number of times of erasure are measured with respect to each block as the minimum unit of data erasure. Then, data in a block being used and least recently erased is transferred to a free block which has been erased more number of times than the block in use by a predetermined value or more. With this, the blocks are equally exhausted.
In the NAND flash memory in which data is written to each logical sector and erased from each block formed of a plurality of logical sectors, as rewriting is performed, the block contains a logical sector that stores invalid data and a logical sector that stores valid data, i.e., some free space exists in the block. To effectively use the storage area, compaction is performed in which the latest effective data are collected from low-density blocks and rewritten to another block.
In conventional technologies, although wear leveling and compaction are similar in that both are techniques to transfer data, they are performed independently. This results in a redundant configuration and heavier burden in development or the like.